import { patch } from './apis'
import { piniaSymbol } from './rootStore'

export default () => {
    const piniaStore = {}

    const setSubStore = (name, store) => {
        if (!piniaStore[name]) {
            piniaStore[name] = store
            piniaStore[name].$patch = patch
        }
        return piniaStore
    }

    const install = (app) => {
        app.provide(piniaSymbol, setSubStore)
    }

    return {
        install
    }
}